import asyncio
from botpy import logging

from botpy.message import GroupMessage
import datetime

_log = logging.get_logger()


class CultivateProcessor:  # 修炼
    async def on_cultivate(self, msg: GroupMessage):
        current_time = datetime.datetime.now()
        formatted_time = current_time.strftime("%Y-%m-%d %H:%M:%S")
        start_cultivate = await msg._api.post_group_message(
            group_openid=msg.group_openid,
            msg_type=0,
            msg_id=msg.id,
            content=f"\n开始修炼：{formatted_time}\n时长1分钟")
        _log.info(start_cultivate)

        await asyncio.sleep(60)

        current_time_after_sleep = datetime.datetime.now()
        formatted_time_after_sleep = current_time_after_sleep.strftime("%Y-%m-%d %H:%M:%S")
        finish_cultivate = await msg._api.post_group_message(
            group_openid=msg.group_openid,
            msg_type=0,
            msg_id=msg.id,
            content=f"\n闭关修炼结束，时间：{formatted_time_after_sleep}")
        _log.info(finish_cultivate)


class SecludeCultivateProcessor:  # 闭关修炼
    __slots__ = (
    )
